package com.perfma.xtest;

import com.google.common.collect.Lists;

import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author: junhui.si
 * @date: 2021-03-16 18:41
 **/
public class ComDemo {

    public static void main(String[] args) throws InterruptedException {
//        ScriptDirectoryVO scriptDirectoryVO = new ScriptDirectoryVO(new Date());
//        Thread.sleep(1000L);
//        ScriptDirectoryVO scriptDirectoryVO2 = new ScriptDirectoryVO(new Date());
//        Thread.sleep(1000L);
//        ScriptDirectoryVO scriptDirectoryVO3 = new ScriptDirectoryVO(new Date());
//
//        List<ScriptDirectoryVO> list = Lists.newArrayList(scriptDirectoryVO2, scriptDirectoryVO3, scriptDirectoryVO);
//        list.sort(Comparator.comparing(ScriptDirectoryVO::getModifyTime).reversed());
//        list.forEach(s -> System.out.println(s.getModifyTime().getTime()));

//        LinkedBlockingQueue<Integer> linkedQueue = new LinkedBlockingQueue(100);
//
//        // Add element using put() method
//        linkedQueue.put(1);
//        linkedQueue.put(2);
//        linkedQueue.put(3);
//        linkedQueue.put(1);
//        linkedQueue.put(1);
//        linkedQueue.put(2);
//        linkedQueue.put(1);
//        linkedQueue.put(1);
//        while (linkedQueue.remove(1)) {
//        }
//        System.out.println(linkedQueue.toString());

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.add(Calendar.SECOND, -1);

        Date endTime = calendar.getTime();
        System.out.println(endTime);
        calendar.add(Calendar.MONTH, -3);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date startTime = calendar.getTime();
        System.out.println(startTime);
    }
}
